home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
-
-
- RS232c PRIMER
- -------------
-
- One of the more mysterious elements of our technical lives is the
- workings of the RS232c communications interface. I will attempt
- to clarify the operation of the subset of the RS232c interface
- most commonly used.
-
- The most common application, today, of an RS232c communications
- interface is to connect some sort of terminal to a computer. When
- the interface was originally specified this was usually done via
- a modem over telephone lines. At the time, computers were large
- mainframes in central locations. All terminals were remote. The
- interface specification was therefore developed to standardize
- the interface between a terminal and a modem. The terminology of
- the specification and the logic of the control signals is from
- the perspective of the terminal.
-
- The simplest type of terminal to interface is an asynchronous
- terminal. This is a terminal which does not require a clock
- signal from the modem in order to interpret the data being
- received. Asynchronous operation is possible with low speed data
- transmissions and single level data encoding schemes. Timing of
- the data is accomplished in an open loop fashion based on the
- known bit rate of the encoded data and the detection of a start
- bit which establishes a reference data transition. The data
- transmission is ended with a stop bit. With ASCII, the data
- encoding scheme we most commonly use, each data transmission
- contains eight bits, or one byte, of data.
-
- The following information will discuss the RS232c interface only
- as it pertains to asynchronous operation.
-
- EIA RS232c
- ----------
- The Electronic Industries Association (EIA) interface standard
- RS232c defines the electrical, control handshaking, transmission
- speed, signal rise time, and impedance parameters of the inter-
- face between a Data Terminal Equipment (DTE) and a Data Commun-
- ications Equipment (DCE). The specification is not concerned with
- the format or content of the data. Nor is the specification
- concerned with control of one DTE by another DTE.
-
- The types of equipment which are typically configured as DTEs
- include video display terminals, printers, and computers. The
-
- - 1 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- types of equipment which are DCEs include modems, multiplexers,
- and switchers.
-
- ELECTRICAL INTERFACE
- --------------------
- The RS232c interface is a digital interface. Information is
- represented by a signal being in one of two states. The voltage
- levels used for the interface are:
-
- +3V to +25V is logic 0 or SPACE (High)
-
- -3V to -25V is logic 1 or MARK (Low)
-
- The signal levels typically used are +12V for SPACE
- and -12V for MARK.
-
- The terminology of the interface is inverted from that of the
- digital logic we are more accustomed to. That is; if a data bit
- or control signal is set "on" in the digital logic, then the
- voltage level at the RS232c interface will go to SPACE. In an
- effort to minimize confusion, I will refer to signals as being
- "High" or "Low".
-
- A voltage level between -3V and +3V is considered to be undefined
- or "floating". For a signal to be considered to have switched
- from say, Low to High, the voltage level of the signal must have
- become greater than +3V. If the voltage went from -12V to 0V the
- signal would still be at a Low condition.
-
- A signal line which is an output is held Low when not active.
- This is true for both control lines and data lines. A signal line
- which is an input is allowed to float and would measure 0V if
- metered without an external input connected to it.
-
- PHYSICAL CONNECTION
- -------------------
- The physical connection of the DTE to the DCE is made through a
- 25 pin D subminiature connector. Usually known as simply a DB-25
- connector. The connector on a DTE should be a male connector or
- plug; the connector on a DCE should be a female connector or
- receptacle.
-
- The specification recommends a maximum cable length between DTE
- and DCE of 50 feet. The limiting factor is the total load capac-
- itance of cable and input circuits of the interface. The maximum
- shunt capacitance is specified as 2500 pF. Special low capac-
- itance cables are available which effectively increase the max-
-
- - 2 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- imum cable length. A typical claim made for these cables is a
- maximum cable length of 500 feet at 9,600 bps.
-
- CONTROL HANDSHAKING
- -------------------
- As mentioned earlier, the logic of the control signals is based
- on the interfacing of a terminal to a modem. That is; the connec-
- tion of DTE to DCE. To fully implement the asynchronous interface
- requires eight signal lines. When a DTE is directly connected to
- a DCE there is a one-to-one correspondence of the signal lines.
- The following diagram illustrates the relationship:
-
- DTE DCE
-
- TD 2 -->----------------------------->-- 2 TD
- RD 3 --<-----------------------------<-- 3 RD
- RTS 4 -->----------------------------->-- 4 RTS
- CTS 5 --<-----------------------------<-- 5 CTS
- DSR 6 --<-----------------------------<-- 6 DSR
- SG 7 ----------------------------------- 7 SG
- DCD 8 --<-----------------------------<-- 8 DCD
- DTR 20 -->----------------------------->-- 20 DTR
-
-
-
- INTERFACING DTE TO DCE
-
-
- The numbers indicate the standard pin assignments. The arrow
- heads indicate which pins are outputs and which are inputs. The
- key to understanding the relationship of the signals is to note
- that, while the pin numbers and designations are identical on the
- DTE and DCE, the signal direction (i.e. whether it is an input or
- an output) reverses.
-
- The pin designations are mnemonics whose meaning is derived from
- the original usage of RS232 as an interface between a terminal
- and a modem.
-
- Transmit Data (TD) - Serial data stream originating from the
- DTE, being passed to the DCE for transmission.
-
- Receive Data (RD) - Serial data stream received by the DCE,
- being passed to the DTE.
-
- Request-To-Send (RTS) - Control signal originating from the
- DTE. The DTE "requests" permission to begin sending serial
- data. When RTS goes High, the DCE begins sending a carrier
-
- - 3 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- signal on the transmission line. At the same time, a CTS timer
- in the DCE is initiated. The CTS timer allows time for the
- carrier signal to propagate along the transmission path and
- stabilize before data is modulated onto the carrier. RTS must
- remain High until the data transmission is completed. When the
- DTE drops RTS, the DCE will stop sending carrier.
-
- Clear-To-Send (CTS) - Control signal originating from the DCE.
- When the CTS timer expires, the DCE sets CTS high to signal
- "permission granted" to the DTE to send data. The DTE will send
- data only while CTS is High.
-
- Data-Set-Ready (DSR) - Control signal originating from the DCE.
- This is a signal indicating the status of the DCE itself. DSR
- must be High for the DTE to initiate a transmission with RTS or
- respond to the DCD signal.
-
- Signal Ground (SG) - Control signal common between DTE and DCE.
-
- Data-Carrier-Detect (DCD) - Control signal originating from the
- DCE. When the DCE detects a carrier signal on the transmission
- line a Carrier-Turnon-Delay timer is initiated. The timer acts
- as a filter of spurious carrier signals. When the timer expires
- the DCD line is raised High. This signals the DTE that data is
- on its way. With the presence of DCD the DTE will "look" at the
- RD line for data. DCD must remain High for the DTE to accept
- data.
-
- Data-Terminal-Ready (DTR) - Control signal originating from the
- DTE. This is a signal indicating the status of the DTE itself.
- DTR must be High for the DCE to respond to the RTS signal.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - 4 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- _____________________________________________________________
- DSR |
- __|
- _____________________________________________________________
- DTR |
- __|
- ____________________________
- RTS | |
- __| |________________________________
- ________________________
- CTS | |
- ______| |________________________________
- _ ___ ___
- TD | | | | | |
- ____________| |_| |_____| |__________________________________
- | |lsb msb |
- | | 8 bits Data | |
-
- > Start Bit > Stop Bit
-
-
- TRANSMIT DATA TIMING
-
-
- ______________________________________________________________
- DSR |
- __|
- ______________________________________________________________
- DTR |
- __|
- _________________________
- DCD | |
- ______| |________________________________
- _ ___ ___
- RD | | | | | |
- ____________| |_| |_____| |__________________________________
- | |lsb msb |
- | | 8 Bits Data | |
-
- > Start Bit > Stop Bit
-
-
- RECEIVE DATA TIMING
-
-
-
-
-
- - 5 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- CONNECTING DTE TO DTE
- ---------------------
- A common application of the RS232c interface is to interconnect
- two DTEs without benefit of modems. In order to successfully do
- this, one must bear in mind the meaning of the signal lines.
- The first point to note is that the transmitted data of one must
- become the received data of the other, and vice versa. The second
- point is that the handshaking logic must be satisfied. The fol-
- lowing diagram illustrates the appropriate cross connections.
-
- DTE DTE
-
- TD 2 -->----------------------------->-- 3 RD
- RD 3 --<-----------------------------<-- 2 TD
- RTS 4 -->--+-------------------------->-- 8 DCD
- CTS 5 --<--+
- DSR 6 --<-----------------------------<-- 20 DTR
- SG 7 ----------------------------------- 7 SG
- DCD 8 --<-------------------------+---<-- 4 RTS
- +--->-- 5 CTS
- TR 20 -->----------------------------->-- 6 DSR
-
-
- DTE TO DTE CONNECTION
-
- The DTE on the right has had its pin numbers reordered in order
- to simplify the appearance of the drawing.
-
- This cable configuration is known variously as a "Null Modem" or
- a "Cross Connect Cable".
-
- CONNECTING DCE TO DCE
- ---------------------
- Connecting DCE directly to DCE is a less common arrangement than
- the other two configurations. The same rules apply as for the DTE
- to DTE configuration. The following diagram illustrates the
- appropriate cross connections.
-
-
-
-
-
-
-
-
-
-
-
- - 6 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- DCE DCE
-
- TD 2 --<-----------------------------<-- 3 RD
- RD 3 -->----------------------------->-- 2 TD
- RTS 4 --<-----------------------------<-- 8 DCD
- CTS 5 -->- N.C.
- DSR 6 -->----------------------------->-- 20 DTR
- SG 7 ----------------------------------- 7 SG
- DCD 8 -->----------------------------->-- 4 RTS
- N.C. -<-- 5 CTS
- DTR 20 --<-----------------------------<-- 6 DSR
-
-
- DCE TO DCE CONNECTION
-
- The DCE on the right has its pin numbers reordered in order to
- simplify the appearance of the drawing.
-
- FLOW CONTROL
- ------------
- It must be understood that the control signal handshaking orig-
- inated to regulate the usage of a half-duplex transmission med-
- ium. That is the lowest common denominator of the communications
- world. A half-duplex medium is one on which a carrier can be sent
- in only one direction at a time. The modems are normally in a
- "listening" mode and can only send out a carrier if no other
- carrier exists on the transmission line. The hand shaking is
- primarily concerned with controlling, or signalling the presence
- of, the carrier. This carrier control is also required in a
- multi-drop application where more than two modems must share the
- same transmission line. The handshaking does not provide end-to-
- end flow control between the DTE.
-
- End-to-end flow control is the responsibility of the DTE data
- protocol. This is outside the definition of RS232c but does
- require some discussion here.
-
- End-to-end flow control is generally accomplished with the
- Xon/Xoff protocol. These are specific ASCII characters which are
- transmitted as part of the data stream between DTE. DTE which use
- Xon/Xoff must have input data buffers. Data is placed in the
- input buffer at the rate of the communications link. If the DTE
- cannot process the data as fast as it enters the buffer, the
- buffer will begin to fill up. When the buffer reaches a certain
- percentage of full, the DTE must temporarily stop receiving data.
- It will send the Xoff character to the sending DTE. The Xoff is
- sent before the input buffer is 100% full because there will be a
- significant delay before the Xoff can be received and processed
-
- - 7 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- at the sending DTE. In the mean time the data transmissions will
- have continued.
-
- The sending DTE will suspend transmissions until an Xon character
- is received. When the input buffer is emptied the receiving DTE
- will send an Xon.
-
- OTHER COMMUNICATIONS PARAMETERS
- -------------------------------
- There are several other parameters which are encountered when
- configuring a RS232c connection, which are not part of the RS232
- specification. These parameters deal with the data protocol being
- used by the DTE and DCE and terminal and modem setup.
-
- Bit Rate
- --------
- The bit rates (frequently called baud rate) of a pair of inter-
- connected equipment must be the same. The bit rate of the RS232
- port is independent of, and has no direct relationship to,
- other timing parameters in a piece of equipment or a system. A
- common problem is encountered with printers where the printer
- is capable of printing at, for example, 30 characters per
- second (cps) but the RS232 interface has been set at 9600 bits
- per second (960 cps). All goes well until the input buffer
- overflows; at which point, if Xon/Xoff flow control is not
- implemented, the incoming data is thrown away.
-
- The point to remember is if end-to-end flow control is not
- available, the bit rate must be compatible with the slowest
- element of the system.
-
- Number of Data Bits
- -------------------
- The number of data bits per character used by a pair of inter-
- connected equipment must be the same. With ASCII data the
- number of data bits is either 7 bits or 8 bits. The standard
- ASCII table requires only 7 bits to represent all its charac-
- ters. The most significant bit, the eighth bit, is used for a
- parity check of the first seven. When an extended group of
- ASCII characters are used the eighth bit is used to provide an
- additional 128 characters. The extended ASCII characters are
- generally unique to a particular manufacturer's equipment.
- Control codes and Function buttons typically generate extended
- ASCII codes. When the eighth bit is used for data there is no
- parity check of the data bits.
-
-
-
-
- - 8 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- Odd or Even Parity
- ------------------
- The parity of a pair of inter-connected equipment must be the
- same. The parity bit is the eighth data bit. It is only used if
- 7 bits of data has been specified. The parity bit is set or
- reset to give the total 8 bit data byte either an odd or even
- bit count. For example if even parity is chosen, the data "3C"
- would be transmitted as "3C". The data "1C" would be trans-
- mitted as "9C". The most significant bit, bit eight, would be
- set to give the data byte an even bit count.
-
- If eight bits data has been chosen, the odd/even parity choice
- is a "don't care".
-
- Number of Stop Bits
- -------------------
- The number of stop bits will normally be one. The choice is a
- throwback to earlier mechanical DTE such as teletypes which
- required two stop bits. Modern electronic equipment almost
- invariably uses one stop bit.
-
- Xon/Xoff Flow-Control
- ---------------------
- If available, this parameter should be selected. This is the
- preferred method of accomplishing flow-control. For flow con-
- trol to work, both DTE of a pair of DTE must have Xon/Xoff
- enabled.
-
- Modem Timers - Leased Line
- --------------------------
- There are three timers likely to be encountered in a leased
- line modem. The Clear-To-Send timer determines the delay bet-
- ween when a modem receives the RTS signal and begins transmit-
- ting carrier, until it signals CTS to the DTE. This timer value
- must be sufficient to allow the carrier signal time to prop-
- agate to the remote DCE and for the remote DCE to raise its DCD
- signal.
-
- The Carrier Detect Delay timer determines the delay between
- when a carrier is first received and when the DCD signal is
- raised. The timer value is chosen to give sufficient time for
- the carrier signal to stabilize. The timer also acts as a
- filter of spurious signals. The CTS timer of the transmitting
- modem must be of longer duration then the DCD delay timer in
- the receiving modem.
-
- The Carrier Turnoff Delay timer is used to maintain a carrier
- signal on the transmission line for a short period of time
-
- - 9 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- after the RTS signal goes low. This delay allows time for the
- data to complete propagating to the remote modem.
-
- Modem Timers - Dial-Up
- ----------------------
- There are three timers of particular significance in dial-up
- modems. The Connect Delay timer is initiated when a modem
- completes dialing a number. The delay is the maximum amount of
- time the modem will wait for an answering carrier from a remote
- modem. This value is typically defaulted to 30 seconds. This
- timer often must be made larger if long distance connections
- are being attempted.
-
- The Carrier Detect Delay timer determines how long a carrier
- signal must be present before the receiving modem will recog-
- nize it. This timer is initiated each time a carrier signal is
- detected. A typical default value is 600 ms., which is normally
- sufficient.
-
- The Carrier Loss Delay timer is used to detect a loss of car-
- rier from a remote modem. When the timer expires the local
- modem is hung up. The timer allows short duration carrier
- dropouts to occur without initiating a disconnect. The value of
- this timer must be greater then the Carrier Detect Delay timer.
-
- Baud Rate
- ---------
- Baud rate is a measure of transmission rate. It is used to spec-
- ify the signal rate on a transmission line. It is frequently
- mistakenly used to refer to the data rate of the RS232 interface.
- The data rate is measured in bits per second. A baud is a signal
- element which can be encoded with one or more bits.
-
- A transmission line's baud rate is limited by its bandwidth. The
- typical transmission line is a voice grade telephone line with a
- bandwidth of approximately 2700 Hz. This puts a practical limit,
- of approximately 2000 Bd., on the baud rate. If a modem uses a
- modulation scheme which produces a one to one equivalency in bps
- and baud, the RS232 data rate will be limited to 2000 bps. One
- such scheme is Frequency Shift Keying (FSK). In this scheme, the
- two different data levels are represented by two different fre-
- quencies. The lower frequency must be at least equal to the data
- rate. This is the least expensive modulation scheme to implement.
- This is the reason for 1200 baud being the most commonly used
- telephone data rate.
-
- In order to transmit at higher data rates, each element of the
- transmission signal must be encoded with more than one bit. As an
-
- - 10 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- example the most common encoding method used to transmit data at
- 2400 bps is Phase Shift Keying (PSK). In this scheme the data is
- sampled two bits at a time. The samples are known as dibits.
- There are four possible dibits; 00, 01, 10, 11. The dibits are
- applied to a phase shifter which changes the phase angle of the
- carrier signal by one of four possible phase shifts. The phase
- shifts are 90 degrees apart. The result is a complex-frequency
- signal of 1200 baud.
-
- WHEN RS232 IS NOT RS232
- -----------------------
- The main stumbling block to successfully interfacing to devices
- equipped with RS232 ports, is the variety of ways the ports may
- be implemented while still claiming to be RS232. Armed with an
- understanding of the RS232 specification, it is sometimes pos-
- sible to work around the limitations of a modified RS232 port.
- The following table gives some common corruptions of the RS232
- specification and possible workarounds when connecting to a fully
- implemented RS232 port.
-
- MODIFICATION LIMITATION or WORK-AROUND
- ----------------------------------------------------------------
- Female type D connector on Make up cable with male con-
- DTE. nector.
-
- 9 pin D connector. Make up cable (or use adapter
- cable) with 9 pin connector.
-
- Non-standard pinout. Make up cable with appro-
- priate pinout.
-
- A terminal, CPU, printer, When connecting a modem to
- etc. with its port configured this device, use a cable
- as DCE. normally intended to inter-
- connect two DCEs.
- When connecting another DTE
- to this device, use a one-to-
- one cable.
-
- A DTE whose RTS line is This terminal cannot be used
- always high. with DCE requiring a switched
- RTS. Such DCEs are half-
- duplex modems, multi-drop
- modems, and port switchers.
-
- A DTE whose DTR line is Not normally a problem.
- always high.
-
-
- - 11 -
-
-
-
-
-
- Ian Friskney, BAS - Toronto, August 1987
- RS232c Primer
-
-
- A DTE whose DTR line is not Jumper DSR to DTR on the DCE.
- present.
-
- A DTE which is not controlled Data from this terminal will
- by CTS. i.e. CTS will be be lost if the DCE is not
- assumed to be high all the ready to transmit data as
- time. soon as RTS is raised.
-
- A DTE which ignores the DSR The DTE will not be able to
- line. detect the readiness of the
- DCE.
-
- A DTE which is not controlled The DTE may receive spurious
- by DCD. i.e. DCD will be data on the RD line. The DTE
- assumed to be high all the may not be able to detect a
- time. connect with dial-up modems.
-
- Interface uses 0V as Low Will not work with a port
- signal and 5V as High signal. configured to meet the RS232c
- specification.
-
- A DCE whose DSR signal is The DTE will not be able to
- high all the time. detect the status of the DCE.
-
- A DCE whose DCD signal is The DTE will not be able to
- high all the time. detect a connect condition on
- a dial-up modem.
-
- A DCE whose DSR signal is not The DTE will not respond to
- present. the DCE. Jumper DTR to DSR at
- the DTE to satisfy the DTE.
-
- A DCE whose CTS signal is not A problem with command mode
- present or is low. of some dial-up modems.
- Jumper CTS to RTS at the DTE
- to satisfy the DTE.
-
-
-
-
-
-
-
-
-
-
-
-
- - 12 -
-